package stylistcrm.core.services.resource;

import stylistcrm.core.services.resource.exception.DeleteFileException;
import stylistcrm.core.services.resource.exception.UploadFileException;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Created by yanwc on 2016/8/21.
 * 附件服务
 */

public interface ObjectResourceService {

    /***
     * 预保存附件
     * @param stream 文件流
     * @param objectName 附件对应实体类型名称（可以是实体的类全名名称）
     * @param tempId 附件临时编号
     * @return 返回真实的可访问的图片地址
     * @throws IOException
     * @throws Exception
     */
    String preSave(InputStream stream, String fileName, String objectName, String tempId, String creator, long creatorId)
            throws IOException,UploadFileException,Exception;

    /**
     * 文件中保存
     * @param sourceFileFullName
     * @param fileName
     * @param objectName
     * @param tempId
     * @return
     */
    String preSave(String sourceFileFullName,String fileName,String objectName,String tempId,String creator,long creatorId) throws IOException, Exception;

    /**
     * 将临时附件更新为正式编号
     * @param tempId 临时编好
     */
    void save(String tempId,long objectId) throws ClassNotFoundException;

    /**
     * 删除附件
     * @param objectId 实体对象的唯一编号
     * @param objectName 对象类型名称
     * @return
     */
    boolean removeImage(long objectId,String objectName) throws DeleteFileException;

}
